<include file="public:header" />
<include file="public:left" />
<style>
    td {
        text-align: center;
    }
</style>
<style type="text/css" src="__STATIC__/admin/css/style.css" ></style>
<style type="text/css" src="__STATIC__/admin/js/laydate/need/laydate.css" ></style>
<script src="__STATIC__/admin/js/laydate/laydate.js"></script>
<section>
    <div class="page_title">
        <h2 class="fl">活动列表</h2>
        <a class="fr" href="{:url('Activity/add')}">活动添加</a>
    </div>
    <table class="table">
        <tr>
            <th>活动id</th>
            <th>活动标题</th>
            <th>活动时间</th>
            <th>抽奖规则</th>
            <th>活动状态</th>
            <th>操作</th>
        </tr>

        <volist name="list" id="vo" key="k">
        <tr>
            <td>
                {$vo.id}
            </td>
            <td>
                {$vo.title}
            </td>
            <td>
                {$vo.start_time} - {$vo.end_time}
            </td>
            <td>{$vo.lottery_time}天抽{$vo.number_draws}次</td>
            <td><if condition="$vo.status eq 1">开启<else />关闭</if></td>
            <td>
                <if condition="$vo.status eq 1">
                    <a href="javascript:void(0)" status="-1" activity_id="{$vo.id}"  id="" class="inner_btn close_activity">活动关闭</a>  
                <else />
                    <a href="javascript:void(0)" status="1" activity_id="{$vo.id}"  id="" class="inner_btn close_activity">活动开启</a>
                </if>
                <a href="javscript:void(0)"  id="{$vo.id}" class="inner_btn have_url">活动链接</a>
                <a href="{:url('Prizes/index',array('activity'=>$vo.id))}" class="inner_btn">奖品列表</a>
                <a href="{:url('Activity/lotteryer',array('activity_id'=>$vo.id))}" class="inner_btn">抽奖人设置</a>
                <a href="{:url('Activity/edit',array('activity_id'=>$vo.id))}" class="inner_btn">活动内容编辑</a>
            </td>
        </tr>
        </volist>
    </table>
    {$list->render()}
</section>

<!--tabStyle-->
<script>
    $(".close_activity").click(function(){
        var id = $(this).attr('activity_id');
        var status = $(this).attr('status');

        $.post("{:url('Activity/index')}",{id: id,status:status}, function (result) {
            if (result.code == '0') {
                layer.alert(result.msg);
            } else {
                layer.alert(result.msg, {
                    btn: ['确定']
                },
                function (index, item) {
                    location.reload();
                });
            }
        });

    });

    $(".have_url").click(function(){
        var id = $(this).attr('id');
        var url = "{$url}";

        url = url + "?id="+id;
        layer.alert(url);
    })
</script>
</div>
</section>
</body>

</html>